<template>
  <!-- 歌单页面 潘敏同学-->
  <div class="song-list">
    <!-- 歌单详情：封面+描述 -->
    <div class="banner">
      <div
        class="mask"
        :style="{ background: 'url(' + playlistInfo.coverImgUrl + ')' }"
      ></div>
      <div class="pic">
        <div class="dscrip">
          <img :src="playlistInfo.coverImgUrl" width="94px" height="94px" />
        </div>
        <div class="dscrip">{{ playlistInfo.description }}</div>
      </div>
    </div>
   <!-- 歌单列表 -->
    <div v-for="(item, idx) in listsong" :key="idx" class="song-div" @click="goPlay(item)">
      <p class="song-name">
        <router-link :to="'/play/' + item.id">{{ item.al.name }}</router-link>
        <van-icon name="play-circle-o" class="start" />
      </p>
      <p class="artist-name">
        <i class="sq"></i>
        {{ item.ar[0].name }}
      </p>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      // 保存歌单详情
      playlistInfo: [],
      listsong: {},
      keyword: "",
    };
  },
  created() {
    this.getPlaylistDetail();
  },
  methods: {
    //获取歌单详情
    getPlaylistDetail() {
      let id = this.$route.params.id;
      this.$http("/playlist/detail", { params: { id } })
        .then((res) => {
          this.playlistInfo = res.data.playlist;
          this.getlistsong(res.data.playlist);
        })
        .catch((err) => {
          console.log(err);
        });
    },

    //获取歌单列表
    getlistsong(e) {
      this.$http("/playlist/detail?id=" + e.id)
        .then((res) => {
          console.log(res.data.playlist.tracks);
          this.listsong = res.data.playlist.tracks;
        })
        .catch((err) => {
          console.log(err);
        });
    },
    //点击歌单列表，跳转到歌单播放页面
    goPlay(e){
      console.log(e.id)
        this.$router.push("/play/" + e.id);
    }
  },
};
</script>

<style scoped>
.song-list .banner {
  width: 100%;
  height: 180px;
  position: relative;
  overflow: hidden;
  margin-top: 0;
  padding-top: 0;
  padding-left: 0;
}
.song-list .mask {
  width: 100%;
  height: 180px;
  z-index: -1;
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  right: 0;
  background-repeat: no-repeat;
  background-size: cover;
  /* background-position: 50%; */
  filter: blur(20px);
  transform: scale(1.5);
  padding-left: 0;
}
.banner .pic {
  top: 25%;
  bottom: 0;
  z-index: 2;
  padding-left: 0px;
  box-sizing: border-box;
  position: relative;
  padding-left: 0;
}
.dscrip {
  color: white;
  width: 140px;
  height: 94px;
  font-size: 13px;
  margin-left: 35px;
  float: left;
  font-style: italic;
  text-overflow: clip;
  overflow: hidden;
  padding-left: 0;
}
.song-list {
  border-bottom: 1px solid #f4f4f4;
  font-size: 15px;

  position: relative;
}
.singer {
  color: #666;
  font-size: 13px;
  margin-top: 2px;
}
.rank {
  position: absolute;
  top: 0;
  left: 8px;
  font-size: 18px;
  line-height: 63px;
}
.start {
  font-size: 30px;
  color: gray;
  margin-right: 10px;
  float: right;
}
.sq {
  /* 不独占一行的块级元素 */
  display: inline-block;
  width: 14px;
  height: 10px;
  background-image: url("../../static/img/index_icon_2x.png");
  background-size: 186.75px 109.125px;
  background-position: 0 0;
}
.song-div {
  padding-left: 10px;
  padding-right: 10px;
}
</style>